﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class kecheng_kecheng_search_free : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            //Session["sTittle"] = "课程查询";
            Session["sUsername"] = "guest";
            Session["sUsername1"] = "来访者";
            Session["sRole"] = "学员";
            Session["sJigou"] = "远程教育平台";
            //以下取得参数（在masterpage中定义的zxdpkey,zxdptype2)
            //string zxdkey = Request.QueryString.Get("zxdpkey");
            string zxdkey = string.Empty;

            string zconj;
            if (zxdkey == "")
            {
                zconj = "1=1";
            }
            else
            {
                //zconj = "name='" + zxdkey + "'";
                zconj = "[name] like '%" + zxdkey + "%'";
            }
            //取得参数完毕

            zconj = "SELECT k.[id],k.[name],k.[xuefei],a.[username1] FROM [kecheng] k inner join [account] a on k.[laoshi]=a.[username] WHERE " + zconj + " AND [confirm]='终审通过' AND [fabuzt]='公开课程' ORDER BY k.[xtsj2] DESC";
            SqlDataSource1.SelectCommand = zconj;
        }
    }


    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowIndex != -1)
        {
            int id = e.Row.RowIndex + 1;
            e.Row.Cells[0].Text = id.ToString();
        }


    }
    protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {
        if (e.NewSelectedIndex >= 0)
        {
            string zsql = "SELECT k.[id],k.[name],k.[xuefei],k.[jigou],k.[kechenglx],k.[fabuzt],k.[jifen],k.[jianjie],a.[username1] FROM [kecheng] k inner join [account] a on k.[laoshi]=a.[username] where k.[id]=" + GridView1.Rows[e.NewSelectedIndex].Cells[2].Text;
            SqlDataSource2.SelectCommand = zsql;
        }
        else
        {
            DetailsView1.Visible = false;
        }
    }
}






